<?php
//------------------------------------------------------------------------------
    class objSession {
        protected $_id='session_id';

      function __construct($id) {
          $this->_id = $id;
          @session_start();
      }// constructor

      function clear($name=false) {
        @session_start();
        if( is_array($_SESSION) ) {
            if( $name ) {
                unset($_SESSION[$this->_id.'_'.$name]);
            } else {
                foreach($_SESSION as $ses_name => $ses_value)
                    if( 0===strpos($ses_name, $this->_id) ) unset($_SESSION[$ses_name]);
            }
        }
      } //clear

      function put($name, $value) {
         @session_start();
         $_SESSION[$this->_id.'_'.$name] = $value;
      } //Put

      function get($name) {
         if (is_array($_SESSION) && array_key_exists($this->_id.'_'.$name, $_SESSION))  return $_SESSION[$this->_id.'_'.$name];
      } //Get

      function putCookie($name, $value, $expire=false, $path=false) {
         setcookie($this->_id.'_'.$name, $value, $expire, $path);
      } //PutCookie

      function getCookie($name) {
         return $_COOKIE[$this->_id.'_'.$name];
      } //GetCookie

      function isEmpty($name='user') {
         return (is_array($_SESSION) && !array_key_exists($this->_id.'_'.$name, $_SESSION) || !$_SESSION[$this->_id.'_'.$name]);
      } //isEmpty

      function isExists($name) {

         return (is_array($_SESSION) &&  array_key_exists($this->_id.'_'.$name, $_SESSION) );
      }//isExists

      function isExistsCookie($name) {
         return (is_array($_COOKIE) &&  array_key_exists($this->_id.'_'.$name, $_COOKIE) );
      }//isExists

      function getSessID() {
         return $this->_id;
      } //GetCookie

   }//class Session

//------------------------------------------------------------------------------
?>
